package com.wbp.cms.core.product.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.wbp.cms.client.product.domain.ProductDO;
import com.wbp.cms.client.product.query.ProductQuery;
import com.wbp.cms.core.dao.BaseDao;


/**
 * @Description:
 * @Department:
 * @author andy.lhc
 * @date 2016年3月9日 下午2:21:09
 */
@Repository("productDAO")
public class ProductDAO extends BaseDao {

   public Long  insert(ProductDO  productDO){
     super.insert("ProductMapper.insert", productDO) ;
     return  productDO.getId() ;
   }
   
   public int  update(ProductDO  productDO){
       return  super.update("ProductMapper.update", productDO) ;
   }
   
   /**
    * 减库存
    * @param productDO
    * @return
    */
   public int decStock(ProductDO  productDO){
     return  super.update("ProductMapper.decStock", productDO) ;
   }
   
   public ProductDO  load(Long  id){
     Object obj = super.selectOneObject("ProductMapper.load", id) ;
     return obj == null ? null : (ProductDO)obj ;
   }
   
   public List<ProductDO>  query(ProductQuery  productQuery){
     return super.selectList("ProductMapper.query", productQuery) ;
   }
   
   public Integer  queryCount(ProductQuery  productQuery){
     Object obj = super.selectOneObject("ProductMapper.queryCount", productQuery) ;
     return obj == null ? null : (Integer)obj ;
   }
   
   
}
